package com.itheima.demo01;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class IteratorDemo01 {
    public static void main(String[] args) {
        //迭代器
        //1.创建集合
        Collection<String> list = new ArrayList<>();

        list.add("aa");
        list.add("bb");
        list.add("cc");
        list.add("dd");

        //2.创建迭代器对象
        Iterator<String> it = list.iterator();

        //3.循环获取数据
        while (it.hasNext()){
            String str = it.next();
            System.out.println(str);
        }

    }
}
